package liumengbaio.lolzhangyoubao.Activity.Activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;

import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/7.
 */
public class HelpSay extends AppCompatActivity implements View.OnClickListener {
    private RelativeLayout relative1, relative2, relative3,
            relative4, relative5, relative6,
            relative7, relative8, relative9,
            relative10, relative11, relative12,
            relative13, relative14, gone1, gone2, gone3, gone4, gone5, gone6, gone7, gone8, gone9, gone10, gone11, gone12, gone13, gone14;
    private Button flag1, flag2, flag3, flag4,
            flag5, flag6, flag7, flag8,
            flag9, flag10, flag11, flag12,
            flag13, flag14, head_left_title;
    private boolean flag = true;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.help_say_activity);
        initView();
        initData();
    }

    private void initData() {
        relative1.setOnClickListener(this);
        relative2.setOnClickListener(this);
        relative3.setOnClickListener(this);
        relative4.setOnClickListener(this);
        relative5.setOnClickListener(this);
        relative6.setOnClickListener(this);
        relative7.setOnClickListener(this);
        relative8.setOnClickListener(this);
        relative9.setOnClickListener(this);
        relative10.setOnClickListener(this);
        relative11.setOnClickListener(this);
        relative12.setOnClickListener(this);
        relative13.setOnClickListener(this);
        relative14.setOnClickListener(this);
        flag1.setOnClickListener(this);
        flag2.setOnClickListener(this);
        flag3.setOnClickListener(this);
        flag4.setOnClickListener(this);
        flag5.setOnClickListener(this);
        flag6.setOnClickListener(this);
        flag7.setOnClickListener(this);
        flag8.setOnClickListener(this);
        flag9.setOnClickListener(this);
        flag10.setOnClickListener(this);
        flag11.setOnClickListener(this);
        flag12.setOnClickListener(this);
        flag13.setOnClickListener(this);
        flag14.setOnClickListener(this);
        gone1.setOnClickListener(this);
        gone2.setOnClickListener(this);
        gone3.setOnClickListener(this);
        gone4.setOnClickListener(this);
        gone5.setOnClickListener(this);
        gone6.setOnClickListener(this);
        gone7.setOnClickListener(this);
        gone8.setOnClickListener(this);
        gone9.setOnClickListener(this);
        gone10.setOnClickListener(this);
        gone11.setOnClickListener(this);
        gone12.setOnClickListener(this);
        gone13.setOnClickListener(this);
        gone14.setOnClickListener(this);
        head_left_title.setOnClickListener(this);
    }

    private void initView() {
        relative1 = (RelativeLayout) findViewById(R.id.relative1);
        relative2 = (RelativeLayout) findViewById(R.id.relative2);
        relative3 = (RelativeLayout) findViewById(R.id.relative3);
        relative4 = (RelativeLayout) findViewById(R.id.relative4);
        relative5 = (RelativeLayout) findViewById(R.id.relative5);
        relative6 = (RelativeLayout) findViewById(R.id.relative6);
        relative7 = (RelativeLayout) findViewById(R.id.relative7);
        relative8 = (RelativeLayout) findViewById(R.id.relative8);
        relative9 = (RelativeLayout) findViewById(R.id.relative9);
        relative10 = (RelativeLayout) findViewById(R.id.relative10);
        relative11 = (RelativeLayout) findViewById(R.id.relative11);
        relative12 = (RelativeLayout) findViewById(R.id.relative12);
        relative13 = (RelativeLayout) findViewById(R.id.relative13);
        relative14 = (RelativeLayout) findViewById(R.id.relative14);
        gone1 = (RelativeLayout) findViewById(R.id.gone1);
        gone2 = (RelativeLayout) findViewById(R.id.gone2);
        gone3 = (RelativeLayout) findViewById(R.id.gone3);
        gone4 = (RelativeLayout) findViewById(R.id.gone4);
        gone5 = (RelativeLayout) findViewById(R.id.gone5);
        gone6 = (RelativeLayout) findViewById(R.id.gone6);
        gone7 = (RelativeLayout) findViewById(R.id.gone7);
        gone8 = (RelativeLayout) findViewById(R.id.gone8);
        gone9 = (RelativeLayout) findViewById(R.id.gone9);
        gone10 = (RelativeLayout) findViewById(R.id.gone10);
        gone11 = (RelativeLayout) findViewById(R.id.gone11);
        gone12 = (RelativeLayout) findViewById(R.id.gone12);
        gone13 = (RelativeLayout) findViewById(R.id.gone13);
        gone14 = (RelativeLayout) findViewById(R.id.gone14);
        head_left_title = (Button) findViewById(R.id.head_left_title);
        flag1 = (Button) findViewById(R.id.flag1);
        flag2 = (Button) findViewById(R.id.flag2);
        flag3 = (Button) findViewById(R.id.flag3);
        flag4 = (Button) findViewById(R.id.flag4);
        flag5 = (Button) findViewById(R.id.flag5);
        flag6 = (Button) findViewById(R.id.flag6);
        flag7 = (Button) findViewById(R.id.flag7);
        flag8 = (Button) findViewById(R.id.flag8);
        flag9 = (Button) findViewById(R.id.flag9);
        flag10 = (Button) findViewById(R.id.flag10);
        flag11 = (Button) findViewById(R.id.flag11);
        flag12 = (Button) findViewById(R.id.flag12);
        flag13 = (Button) findViewById(R.id.flag13);
        flag14 = (Button) findViewById(R.id.flag14);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.relative1:
                expand_view(gone1, flag1);
                break;
            case R.id.relative2:
                expand_view(gone2, flag2);
                break;
            case R.id.relative3:
                expand_view(gone3, flag3);
                break;
            case R.id.relative4:
                expand_view(gone4, flag4);
                break;
            case R.id.relative5:
                expand_view(gone5, flag5);
                break;
            case R.id.relative6:
                expand_view(gone6, flag6);
                break;
            case R.id.relative7:
                expand_view(gone7, flag7);
                break;
            case R.id.relative8:
                expand_view(gone8, flag8);
                break;
            case R.id.relative9:
                expand_view(gone9, flag9);
                break;
            case R.id.relative10:
                expand_view(gone10, flag10);
                break;
            case R.id.relative11:
                expand_view(gone11, flag11);
                break;
            case R.id.relative12:
                expand_view(gone12, flag12);
                break;
            case R.id.relative13:
                expand_view(gone13, flag13);
                break;
            case R.id.relative14:
                expand_view(gone14, flag14);
                break;
            case R.id.head_left_title:
                finish();
                break;
        }
    }

    private void expand_view(RelativeLayout gone, Button btn) {
        if (flag) {
            gone1.setVisibility(View.GONE);
            gone2.setVisibility(View.GONE);
            gone3.setVisibility(View.GONE);
            gone4.setVisibility(View.GONE);
            gone5.setVisibility(View.GONE);
            gone6.setVisibility(View.GONE);
            gone7.setVisibility(View.GONE);
            gone8.setVisibility(View.GONE);
            gone9.setVisibility(View.GONE);
            gone10.setVisibility(View.GONE);
            gone11.setVisibility(View.GONE);
            gone12.setVisibility(View.GONE);
            gone13.setVisibility(View.GONE);
            gone14.setVisibility(View.GONE);
            gone.setVisibility(View.VISIBLE);
            btn.setVisibility(View.INVISIBLE);
            flag = false;
        } else {
            gone1.setVisibility(View.GONE);
            gone2.setVisibility(View.GONE);
            gone3.setVisibility(View.GONE);
            gone4.setVisibility(View.GONE);
            gone5.setVisibility(View.GONE);
            gone6.setVisibility(View.GONE);
            gone7.setVisibility(View.GONE);
            gone8.setVisibility(View.GONE);
            gone9.setVisibility(View.GONE);
            gone10.setVisibility(View.GONE);
            gone11.setVisibility(View.GONE);
            gone12.setVisibility(View.GONE);
            gone13.setVisibility(View.GONE);
            gone14.setVisibility(View.GONE);
            gone.setVisibility(View.GONE);
            btn.setVisibility(View.VISIBLE);
            flag = true;
        }

    }
}
